package com.yanqu.road.entity.player;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.utils.date.DateHelper;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author ：zfr
 * @date ：2021/10/21 18:45
 */
public class PatronsFishBindingData extends DataObject {
    private long userId;
    private int fishId;
    private int patronsId;
    private List<Integer> activityIdList = new ArrayList<>();
    private long lastUpdateTime;
    private int systemId;
    private long systemEndTime;//秒

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public int getFishId() {
        return fishId;
    }

    public void setFishId(int fishId) {
        this.fishId = fishId;
    }

    public int getPatronsId() {
        return patronsId;
    }

    public void setPatronsId(int patronsId) {
        if (this.patronsId != patronsId) {
            this.patronsId = patronsId;
            setUpdateOption();
        }
    }

    public List<Integer> getActivityIdList() {
        return activityIdList;
    }

    public void addActivityId(int activityId) {
        if (activityIdList.contains(activityId)) {
            return;
        }
        activityIdList.add(activityId);
        setUpdateOption();
    }

    public void removeActivityId(int activityId) {
        if (!activityIdList.contains(activityId)) {
            return;
        }
        int index = activityIdList.indexOf(activityId);
        activityIdList.remove(index);
        if (activityIdList.isEmpty()) {
            if (DateHelper.getCurrentSecond() > systemEndTime) {
                setPatronsId(0);
            }
        }
        setUpdateOption();
    }

    public void setActivityIdList(List<Integer> activityIdList) {
        if (!Objects.equals(this.activityIdList, activityIdList)) {
            this.activityIdList = activityIdList;
            setUpdateOption();
        }
    }

    public long getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(long lastUpdateTime) {
        if (!Objects.equals(this.lastUpdateTime, lastUpdateTime)) {
            this.lastUpdateTime = lastUpdateTime;
            setUpdateOption();
        }
    }

    public int getSystemId() {
        return systemId;
    }

    public void setSystemId(int systemId) {
        if (this.systemId != systemId) {
            this.systemId = systemId;
            setUpdateOption();
        }
        this.systemId = systemId;
    }

    public long getSystemEndTime() {
        return systemEndTime;
    }

    public void setSystemEndTime(long systemEndTime) {
        if (this.systemEndTime != systemEndTime) {
            this.systemEndTime = systemEndTime;
            setUpdateOption();
        }
        this.systemEndTime = systemEndTime;
    }

    public void addSystem(int systemId, long systemEndTime){
        if (systemEndTime > this.systemEndTime){
            this.systemId = systemId;
            this.systemEndTime = systemEndTime;
            setUpdateOption();
        }
    }
}
